
function validateForm ( form ) {
   for ( var e = 0; e < form.elements.length; e ++ ) {
      var el = form.elements [ e ];
      if ( el.type == 'text' || el.type == 'textarea' || 
         el.type == 'password' || el.type == 'file' ) {
         // check text fields
         if ( el.value == '' ) {
            alert ( 'Please fill out the ' + el.name + ' field' );
            el.focus ( );
            return false;
         }
      }
      else if ( el.type.indexOf ( 'select' ) != -1 ) {
         // check selectable dropdown menus
         if ( el.selectedIndex == -1 ) {
            alert ( 'Please select a value for ' + el.name );
            el.focus ( );
            return false;
         }
      }
      else if ( el.type == 'radio' ) {
         // check radio button groups
         var group = form [ el.name ];
         var checked = false;
         if ( !group.length ) checked = el.checked;
         else
            for ( var r = 0; r < group.length; r ++ )
               if ( ( checked = group [ r ].checked ) )
            break;
         if ( !checked ) {
            alert ( 'Please check one of the ' + 
            el.name + ' buttons' );
            el.focus ( );
            return false;
         }
      }
	  if(el.name == 'email'){
		  //check email addresses
		  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		  var address = el.name.value;
		  if(reg.test(address) == false) {
		  alert('Invalid Email Address' + el.name.value);
		  return false;
		  }
	  return true;
	  }
      else if ( el.type == 'checkbox' ) {
         // check checkbox groups
         var group = form [ el.name ];
         if ( group.length ) {
            var checked = false;
            for ( var r = 0; r < group.length; r ++ )
               if ( ( checked = group [ r ].checked ) )
            break;
            if ( !checked ) {
               alert ( 'Please check one of the ' + 
               el.name + ' checkboxes' );
               el.focus ( );
               return false;
            }
         }
      }
   }
   return true;
}

function validate(form_id,email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }
}